{$layout}

<!-- 检测配置是否有更新 begins -->
<div class="ui icon message warning" v-if="statusChanged">
    <i class="exclamation circle icon large"></i>
    代理服务已被修改，<a href="" v-on:click.prevent="restart()">点此重启后生效</a>
</div>

{$var "header"}
<script type="text/javascript" src="/_/@default/proxy/@global.js"></script>
{$end}
<!--  检测配置是否有更新 end -->

<div>
    {$template "/proxy/menu"}

    <div class="ui text menu blue small">
        <a :href="'/proxy/locations?server=' + proxy.filename" class="ui item active">所有路径规则</a>
        <span class="item">|</span>
        <a :href="'/proxy/locations/add?server=' + proxy.filename"  class="u item">添加新路径规则</a>
    </div>

    <p class="comment" v-if="locations.length == 0">暂时还没有路径规则配置。</p>

    <table class="ui table selectable" v-if="locations.length > 0">
        <thead>
            <tr>
                <th>匹配规则</th>
                <th class="three wide">操作</th>
                <th class="two wide" v-if="locations.length > 1">位置</th>
            </tr>
        </thead>
        <tbody>
            <tr v-for="(location, index) in locations">
                <td>
                    <span style="line-height:2">{{location.pattern}}</span><br/>
                    <span class="ui label tiny olive">{{location.patternTypeName}}</span>
                    <span class="ui label tiny" v-if="!location.on">未启用</span>
                    <span class="ui label tiny" v-if="location.isCaseInsensitive">不区分大小写</span>
                    <span class="ui label tiny" v-if="location.isReverse">反向匹配</span>
                    <span class="ui label tiny" v-if="location.root.length > 0">root</span>
                    <span class="ui label tiny" v-if="location.cachePolicy != null">cache</span>
                    <span class="ui label tiny" v-if="location.headers.length > 0">headers</span>
                    <span class="ui label tiny" v-if="location.websocket">websocket</span>

                    <p v-for="fastcgi in location.fastcgi">
                        <span class="ui label tiny">fastcgi {{fastcgi.pass}}</span>
                    </p>
                    <p v-for="rewrite in location.rewrite">
                        <span class="ui label tiny">rewrite {{rewrite.pattern}} -&gt; {{rewrite.replace}}</span>
                    </p>
                </td>
                <td>
                    <a :href="$url('/proxy/locations/detail', { 'server':filename,'locationId':location.id })">详情</a> &nbsp;
                    <a href="" v-on:click.prevent="deleteLocation(location.id)">删除</a> &nbsp;
                </td>
                <td v-if="locations.length > 1">
                    <a href="" v-if="index > 0" title="上移" v-on:click.prevent="moveUp(index)">上移</a>
                    <a href="" v-if="locations.length > 1 && index < locations.length - 1" title="下移" v-on:click.prevent="moveDown(index)">下移</a>
                </td>
            </tr>
        </tbody>
    </table>
    <p class="comment" v-if="locations.length > 1">所有规则匹配顺序为从上到下。</p>
</div>